﻿@model MyNeighbourhood.Models.EventModel
@using MyNeighbourhood.Helpers;

@{
    ViewBag.Title = "Create";
}
<link href="~/Content/Events.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
@*<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>*@

<h2>Create</h2>

@using (Html.BeginForm("Create", "Events", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(false)

    <fieldset>
        <legend>Event</legend>

        @Html.HiddenFor(model => model.EventId)

        <div class="float-left">
            <div class="editor-field">
                @Html.DropDownListFor(model => model.EventType, (SelectList)ViewBag.EventTypes, "Event type")
                @Html.ValidationMessageFor(model => model.EventType)
            </div>

            <div class="editor-field">
                @Html.TextBoxFor(model => model.Name, new { placeholder = "Name" })
                @Html.ValidationMessageFor(model => model.Name)
            </div>

            <div class="editor-field">
                @Html.DropDownListFor(model => model.Day, new SelectList(Enumerable.Range(1, 31)), "Day", new { style = "width:80px" })
                @Html.DropDownListFor(model => model.Month, new SelectList(Enumerable.Range(1, 12)), "Month", new { style = "width:80px" })
                @Html.DropDownListFor(model => model.Year, new SelectList(Enumerable.Range(2014, 2)), "Year", new Dictionary<string, object> { { "style", "width:80px" } })
                @Html.ValidationMessageFor(model => model.Date)
            </div>

            <div class="editor-field">
                @Html.EditorFor(model => model.Time)
                @Html.ValidationMessageFor(model => model.Time)
            </div>

            <div class="editor-field">
                <label>@Html.RadioButtonFor(model => model.IsPublic, "False") Private event</label>
                <label>@Html.RadioButtonFor(model => model.IsPublic, "True") Public event</label>
                @Html.ValidationMessageFor(model => model.IsPublic)
            </div>

            <div class="section">Location:</div>
            <hr />
            <div class="clearfix"></div>
            <div class="editor-field">
                @Html.TextBoxFor(model => model.Location.Street, new { placeholder = "Street" })
                @Html.ValidationMessageFor(model => model.Location.Street)
            </div>

            <div class="editor-field">
                @Html.TextBoxFor(model => model.Location.Number, new { placeholder = "Number" })
                @Html.ValidationMessageFor(model => model.Location.Number)
            </div>

            <hr />

            <div class="editor-field">
                @Html.TextBoxFor(model => model.Phone, new { placeholder = "Phone" })
                @Html.ValidationMessageFor(model => model.Phone)
            </div>

            <div class="editor-field">
                @Html.TextBoxFor(model => model.Email, new { placeholder = "Email" })
                @Html.ValidationMessageFor(model => model.Email)
            </div>

            <div class="editor-field">
                @Html.TextBoxFor(model => model.Website, new { placeholder = "Website" })
                @Html.ValidationMessageFor(model => model.Website)
            </div>

            <div class="section">This event is for:</div>
            <hr />
            <div class="clearfix"></div>

            @for (int i = 0; i < ViewBag.TargetTypes.Count; i++)
            {
                string text = ViewBag.TargetTypes[i].Name;
                <div>
                    @Html.HiddenFor(x => x.TargetCheck[i].TargetTypeId)
                    @Html.CheckBoxFor(x => x.TargetCheck[i].IsChecked)
                    @Html.LabelFor(x => x.TargetCheck[i].IsChecked, text)
                </div>
            }
            @Html.TextBoxFor(x => x.OtherTargets, new { placeholder = "Others (separated by commas)", style = "width:300px" })
            <hr />
        </div>

        <div class="float-right">
            <div class="editor-field">
                @Html.TextAreaFor(model => model.AdditionalInfo, new { placeholder = "Additional Info" })
                @Html.ValidationMessageFor(model => model.AdditionalInfo)
            </div>

            <div class="section">Participants:</div>
            <hr />
            <div class="clearfix"></div>
            @for (int i = 0; i < Model.Participants.Count; i++)
            {
                <input type="file" name="Image" id="img" accept="image/*" />
                @Html.ValidationMessageFor(model => model.Participants[i].Photo)

                <div class="editor-field">
                    @Html.TextBoxFor(x => x.Participants[i].Name, new { placeholder = "Name" })
                    @Html.ValidationMessageFor(x => x.Participants[i].Name)
                </div>
            
                <div class="editor-field">
                    @Html.TextBoxFor(x => x.Participants[i].Programme, new { placeholder = "Programme" })
                    @Html.ValidationMessageFor(x => x.Participants[i].Programme)
                </div>
            }
            <div id="participants-section">
            </div>

            @Ajax.ActionImageLink("../Images/custom/plus32.png", "Add new participant", "AddParticipant", "Events", new { index = Model.Participants.Count },
            new AjaxOptions { InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "participants-section", HttpMethod = "get" })
            <hr />
            <p>
                <input type="submit" value="Добави" />
            </p>
        </div>

    </fieldset>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
